﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WPFExcelReport.Helpers;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class TPT1YH
    {
        public TPT1YH()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VTXTKON();
            this.DataContext = MV;
            InitializeComponent();

        }

        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            base.Window_Loaded(sender, e);
            TP = "T1";
        }

        public override void SaveCommand(object sender, RoutedEventArgs e)
        {
            TPSave(MV.date, app.User, 0, 10,false);
            base.SaveCommand(sender, e);
        }
        public override void OnSave()
        {
            if (!IsSaved)
                return; 
            base.OnSave();
        }
        public override void PINDLOAD(string pind)
        {
            TBMain.Clear();
            ReSetTXT();
            if (pind.Length == 0)
                return;
            dwData = TBMain.NewRow();
            dwData["TXTKMANDANT"] = app.Mandant;
            dwData["TXTKPIND"] = pind;
            dwData["TXTKFILLER"] = " AND TXTKFILLER='" + TP + "'";
            SResult = TMV.QTXT05(dwData);
            MergeData(SResult, true, true);
            GetTPTxt();
            DEFTPTEXT();
        }
        public override void OnEdit()
        {
            if (!IsEdit)
                return;
            DEFTPTEXT();
            base.OnEdit();
        }
        public override void DEFTPTEXT()
        {
            if (TBMain.Rows.Count > 0)
                return;
            if (IsEdit)
            {
                string txt = "";
                txt = "2101- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2101-";//备注
                TMV.InsertLine(txt);
                txt = "2102- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2102- ";//备注
                TMV.InsertLine(txt);
                txt = "2103- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2103- ";//备注
                TMV.InsertLine(txt);
                txt = "2104- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2104- ";//备注
                TMV.InsertLine(txt);
                txt = "2105- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2105- ";//备注
                TMV.InsertLine(txt);
                txt = "2106- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2106- ";//备注
                TMV.InsertLine(txt);
                txt = "2107- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2107- ";//备注
                TMV.InsertLine(txt);
                txt = "2108- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2108- ";//备注
                TMV.InsertLine(txt);

                txt = "2109- ";//+ MV.date + app.User;
                TMV.InsertLine(txt);
                txt = "2109- ";//备注
                TMV.InsertLine(txt);
                TMV.POSTCHG();
            }
            GetTPTxt();

        }
    }
}
